import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import router from '@/router'
import store from '@/store'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import en from 'element-plus/dist/locale/en.mjs'
import VxeUIAll, { VxeUI } from 'vxe-pc-ui'
import 'vxe-pc-ui/es/style.css'

import VxeUITable from 'vxe-table'
import 'vxe-table/es/style.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import '@/assets/base.scss'
import i18n from '@/lang'
import * as mUtils from '@/utils/mUtils'
import * as api from '@/api'
import '@/permission'
import { setupDirective } from "@/directive";
import "@/styles/index.scss";
// 本地SVG图标
import "virtual:svg-icons-register";
import { ElLoading } from 'element-plus'
// 全局默认参数
VxeUITable.setup({
  version: 0,
  zIndex: 9999, // 想多高就设置多高
  table: {
    autoResize: true,
  },
});
VxeUI.setConfig({
  // authId: 'y5nvlxh7oxkru7pw', // 获取授权后在官网登录后进入“用户中心”查看

})
const app = createApp(App)
const loading = ElLoading.service({
    lock: true,
    text: 'Loading',
    background: 'rgba(255, 255, 255, 0.7)',
  })
setupDirective(app);
app.config.globalProperties.$mUtils = mUtils
app.config.globalProperties.$api = api.default
app.config.globalProperties.$loading = loading
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
// 根据当前i18n语言选择对应的Element Plus语言包
const getElementPlusLocale = () => {
  const locale = i18n.global.locale
  return locale === 'en' ? en : zhCn
}

app.use(router).use(ElementPlus, {
  locale: getElementPlusLocale()
}).use(store).use(i18n).use(VxeUIAll).use(VxeUITable).use(VxeUIAll).mount('#app')
